<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	<%@ include file="../../system/main/main_top.jsp"%> 
	
    <link rel="stylesheet" media="screen" type="text/css" href="static/select2-js/select2.css" />
	</head>
<body>
<div class="container-fluid" id="main-container">
<div id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="icon-home"></i> <a>统计报表</a> <span class="divider">
				<i class="icon-angle-right"></i>
		</span></li>
		<li class="active">活动费用结算报表</li>
	</ul>
	<!--.breadcrumb-->
</div>
<div id="page-content" class="clearfix">
  <div class="row-fluid">
	<div class="row-fluid">
			<!-- 检索  -->
			<form action="activityFeeTransReport/list.do" method="post" name="Form" id="Form">
			<table>
				<tr>
					<td><input class="span10 date-picker" id="lastStart" name="lastStart" value="${pd.lastStartShow}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:120px;" placeholder="交易时间从"/></td>
					<td><input class="span10 date-picker" id="lastEnd" name="lastEnd" value="${pd.lastEndShow}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:120px;" placeholder="交易时间至"/></td>
					<td>&nbsp;&nbsp;</td>
					<td style="vertical-align:top;">
						<input type="text" id="keyword" name="keyword" value="${pd.keyword}" placeholder="这里输入活动发起人手机号码"/>
					</td>
					<td>&nbsp;&nbsp;</td>
					<td style="vertical-align:top;">
						提现状态：
						<select class="chzn-select" name="trans_state" id="trans_state" data-placeholder="请选择核算状态" style="vertical-align:top;width: 120px;">
							<option value="-1" <c:if test="${pd.trans_state=='' || pd.trans_state==null}">selected</c:if>>全部</option>
							<option value="0" <c:if test="${pd.trans_state=='0'}">selected</c:if>>未提现</option>
							<option value="1" <c:if test="${pd.trans_state=='1'}">selected</c:if>>已提交</option>
							<option value="2" <c:if test="${pd.trans_state=='2'}">selected</c:if>>转账成功</option>
							<option value="3" <c:if test="${pd.trans_state=='3'}">selected</c:if>>转账失败</option>
					  	</select>
					</td>
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="searchStatement();"  title="检索"><i id="nav-search-icon" class="icon-search"></i></a></td>
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="exportExcel();" title="导出到EXCEL"><i id="nav-search-icon" class="icon-download-alt"></i></a></td>
				</tr>
			</table>
			<div class="Noprint">
				<i class="icon-circle green"></i>温馨提示：<strong>默认显示从当前月份往前1个月份的数据</strong>
			</div>
			<!-- 检索  -->
			<table id="table_report" class="table table-striped table-bordered table-hover" style="margin-top: 10px;">
				<thead>
					<tr>
						<th>提现人ID</th>
						<th>提现人OPEN_ID</th>
						<th>提现人手机号码</th>
						<th>核算金额</th>
						<th>账户信息</th>
						<th>平台实际到账金额X</th>
						<th>补贴金额X*0.6%</th>
						<th>最终钱包余额X+X*0.6%</th>
						<th>用户申请提现金额 Y</th>
						<th>扣除手续费（Y*0.5%)最低1元 最高25元</th>
						<th>最终可提现金额（Y-Y*0.5%）</th>
						<th>创建时间</th>
						<th>支付批次号</th>
						<th>支付流水号</th>
						<th>提现状态</th>
						<th>操作</th>
					</tr>
				</thead>
										
				<tbody>
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						<c:forEach items="${varList}" var="var" varStatus="vs">
							<tr>
									<td>${var.m_id}</td>
									<td>${var.open_id}</td>
									<td>${var.mobile}</td>
									<td>${var.total_fee}</td>
									<td>${var.account_info}</td>
									<td>${var.rece_actual_amount}</td>
									<td>${var.subsidy_amount}</td>
									<td>${var.final_rece_amount}</td>
									<td>${var.apply_withdraw_amount}</td>
									<td>${var.commission_amount}</td>
									<td>${var.final_withdraw_amount}</td>
									<td>${pd.lastStartShow}-${pd.lastEndShow}</td>
									<td>${var.batch_no}</td>
									<td>${var.serial_no}</td>
									<td>
										<c:if test="${var.trans_state == '0' }">未提现</c:if>
										<font color="green"><c:if test="${var.trans_state == '1' }">已提交</c:if></font>
										<font color="green"><c:if test="${var.trans_state == '2' }">提现成功</c:if></font>
										<font color="red"><c:if test="${var.trans_state == '3' }">提现失败</c:if></font>
									</td>
									<td class="center">
										<div>
											<a class='btn btn-mini btn-info' title="详情" onclick="view('${var.open_id}','${var.m_id}','${var.trans_state}');" style="margin-top: 2px;">详情</a>
										</div>
									</td>
							</tr>
						</c:forEach>
						<!-- 
						<tr>
							<td colspan="100" class="center">您无权查看</td>
						</tr>
						 -->
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				</tbody>
			</table>
			
			<div class="page-header position-relative">
				<table style="width:100%;">
					<tr>
						<td style="vertical-align:top;">
							<!-- <a class="btn btn-small btn-success" onclick="view(1);">查看</a> -->
						</td>
						<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
					</tr>
				</table>
			</div>
		</form>
	</div>
 
	<!-- PAGE CONTENT ENDS HERE -->
  </div><!--/row-->
	
</div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
			<form action="activityFeeTransReport/editActivityFeeTransReport.do" method="post" name="activityFeeTransReportForm" id="activityFeeTransReportForm">
				<input type="hidden" name="lastStartEdit" id="lastStartEdit"/>
				<input type="hidden" name="lastEndEdit" id="lastEndEdit"/>
				<input type="hidden" name="keywordEdit" id="keywordEdit"/>
				<input type="hidden" name="trans_stateEdit" id="trans_stateEdit"/>
			</form>
			<div align="center">
				<a class="btn btn-primary" onclick="save();">核算</a>
			</div>
	
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
		
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
		<script type="text/javascript" src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/select2-js/select2.js"></script>
		<script type="text/javascript" src="static/select2-js/select2.min.js"></script>
		<script type="text/javascript" src="static/select2-js/select2_locale_zh-CN.js"></script>
		<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->	
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<!-- 引入 -->
		
		<script type="text/javascript">
		
		$(top.hangge());
		
		//下拉框
		$(".chzn-select").chosen(); 
		$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
		
		$(function() {
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			//日期框
			$('.date-picker').datepicker();
		});
		
		//检索
		function searchStatement(){
			var start = $("#lastStart").val();  
		    var end = $("#lastEnd").val();  
		    if(start != null && end != null){
		        if(end < start){  
		            alert('结束时间不能早于开始时间！');  
		            $("#lastEnd").focus();  
		            return false;  
		        }  
		          
		        var days = daysBetween(start,end);  
		        if(days>31){  
		            alert('时间跨度不能超过一个月！');  
		            $("#lastEnd").focus();  
		            return false;  
		        }  
		    }  

			$("#Form").submit();
		}
		
		//+--------------------------------------------------    
		//| 求两个时间的天数差 日期格式为 YYYY-MM-dd     
		//+--------------------------------------------------  
		function daysBetween(DateOne,DateTwo)    
		{     
		    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));    
		    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);    
		    var OneYear = DateOne.substring(0,DateOne.indexOf ('-'));    
		    
		    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-'));    
		    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1);    
		    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-'));    
		    
		    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);     
		    return Math.abs(cha);    
		}  
		
		
		function movieFormatResult(result, container, query, escapeMarkup) {
			return result.text;
		}
		
		function exportExcel(){
			var lastStart = $("#lastStart").val();  
		    var lastEnd = $("#lastEnd").val();  
			var trans_state = $("#trans_state").val();
			var keyword = $("#keyword").val();
			window.location.href='<%=basePath%>/activityFeeTransReport/exportExcel.do?lastStart='+lastStart+'&lastEnd='+lastEnd+'&trans_state='+trans_state+'&keyword='+keyword;
		}
		
		//查看
		function view(open_id,m_id,trans_state){
			 var lastStart = $("#lastStart").val();  
		     var lastEnd = $("#lastEnd").val();  
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="详情";
			 diag.URL = '<%=basePath%>/activityFeeTransReport/listDetail.do?lastStart='+lastStart+'&lastEnd='+lastEnd+'&trans_state='+trans_state+'&m_id='+m_id+'&open_id='+open_id;
			 diag.Width = 1200;
			 diag.Height = 800;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//保存
		function save(){
			bootbox.confirm("<font color='red'>确认核算吗? 状态一旦修改则不能恢复!</font>", function(result) {
				if(result) {
					var lastStart = $("#lastStart").val();  
				    var lastEnd = $("#lastEnd").val();  
					var trans_state = $("#trans_state").val();
					var keyword = $("#keyword").val();
					if(trans_state != 0){
						alert("转账状态不正确，无效的提交动作！");
						return false;
					}
					$("#lastStartEdit").val(lastStart);
					$("#lastEndEdit").val(lastEnd);
					$("#trans_stateEdit").val(trans_state);
					$("#keywordEdit").val(keyword);
					$("#activityFeeTransReportForm").submit();
				}
			});
		}
		</script>
	</body>
</html>

